<!--_meta 作为公共模版分离出去-->
<include file='public/_meta'>
<!--/meta 作为公共模版分离出去-->

<title>添加记录</title>
<meta name="keywords" content="">
<meta name="description" content="">
<style type="text/css">
	.ac_results li.ac_over{
		/*background:#d5deff;*/
	}
	.version ul li { line-height: 24px; height: 24px; display: block;float: left; padding: 5px 8px; margin: 10px 10px 0 0; border-radius: 8px; -moz-transition: all 0.5s; -webkit-transition: all 0.5s; -o-transition: all 0.5s; transition: all 0.5s; text-decoration: center }
	.version ul li a { color: #FFF;text-decoration: center }
	/*.version ul li:nth-child(8n-7) { background: #8A9B0F }
	.version ul li:nth-child(8n-6) { background: #EB6841 }
	.version ul li:nth-child(8n-5) { background: #3FB8AF }
	.version ul li:nth-child(8n-4) { background: #FE4365 }
	.version ul li:nth-child(8n-3) { background: #FC9D9A }
	.version ul li:nth-child(8n-2) { background: #EDC951 }
	.version ul li:nth-child(8n-1) { background: #C8C8A9 }
	.version ul li:nth-child(8n) { background: #83AF9B }
	.version ul li:first-child { background: #036564 }
	.version ul li:last-child { background: #3299BB }*/
	.version ul li:hover { border-radius: 0; }
	.version ul li:hover .operate{ color: #5eb95e;}
</style>
</head>
<body>
<article class="page-container">
	<div class="Huialert Huialert-success"><i class="Hui-iconfont">&#xe6a6;</i>
        <p class="c-primary">
            操作提示
        </p>
        <ul>
          <li>添加车机版本</li>

          
          <li>添加后可在下方查看所添加的车机版本 , 并且鼠标移到版本处可查看已添加的<span style="color: red;">版本描述</span>并且<span style="color: red;">删除</span>已添加的版本</li>

        </ul>
    </div>
	<form action="{:url('index/terminal/versionAdd')}" method="post" class="form form-horizontal" id="form-member-add" enctype="multipart/form-data">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车机版本号:</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder="" id="search_text" name="version">
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">描述:</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder=""  name="description">
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
	<div class="mt-30"></div>
	<if condition="$version!=null">
		<span class="c-red">*</span>已添加的版本
		
	</if>
	<div class="mt-10 version">
		<ul class="cl">
			<foreach name='version' item = "val">
			<li class="f-l">
				<div class=""> 
					<button class="btn btn-primary radius" data-toggle="tooltip" data-placement="top" title="{$val.description}">{$val.version}</button>
				</div>
				<div class="ml-15"><a href="javascript:;" class="operate" onclick="versionDel(this,{$val.id})">删除</a> </div>
			</li>
			</foreach>
		</ul>
	</div>
</article>
<!-- c-white -->
<!--_footer 作为公共模版分离出去-->
<include file='public/_footer'>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript" src="__PUBLIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/autocomplete/jquery.autocomplete.js"></script>
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});

	$("#form-member-add").validate({
		rules:{
			version:{
				required:true,
			},
			description:{
				maxlength:32
			}	
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
				success: function(data) { 
				 	var index = parent.layer.getFrameIndex(window.name);
					// parent.$('.btn-refresh').click();
	                if(data['result']==0){
	                
	                	layer.msg(data['msg'], {icon:6,time:1000},function(){

							parent.location.href = '{:url('index/terminal/cars')}';              		
							parent.layer.close(index);
	                	});

	                }else{
	                	layer.msg(data['msg']);

	            	}
            	}
			});
		}
	});

});




function versionDel(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '{:url('index/terminal/versionDel')}',
			data:{'id':id},
			dataType: 'json',
			success: function(data){
				if(data.result == 0){

					layer.msg('已删除!',{icon:6,time:1000});
					$(obj).parents("li").remove();
				}else{
					layer.msg(data['msg']);
				}
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>